#include <string.h>
#include "package_scanner.h"
#include "rda5981_ota.h"




PackageScanner::PackageScanner()
{
}

PackageScanner::~PackageScanner()
{
}

int PackageScanner::scan()
{
    firmware_info_t *firmware_info;
    image_header_t  *staged_header;
	bool upgrade_image_valid = true;
	memset(&_os_info, 0, sizeof(_os_info));
	firmware_info = (firmware_info_t*)(OTA_FW_INFO_ADDR);
	staged_header = (image_header_t*)(OTA_UPGRADE_ADDR);

	strncpy(_os_info.name, "TinyDu", sizeof(_os_info.name) - 1);
	strncpy(_os_info.developer, "Baidu", sizeof(_os_info.developer) - 1);
	strncpy(_os_info.version, (const char*)firmware_info->version, sizeof(_os_info.version) - 1);
	if (upgrade_image_valid)
	{
	    strncpy(_os_info.staged_version, (const char*)staged_header->version, sizeof(_os_info.staged_version) - 1);
	}
    return 0;
}

int PackageScanner::get_os_info(struct os_info& info)
{
	info = _os_info;
    return 0;
}

int PackageScanner::getAppInfo(struct app_info*& info)
{
    return 0;
}
